from random import Random
from random import choice


class ParturitionCode(object):
    """
    生产验证码
    """

    def random_figure(randomlength=4):
        """
               生成四位数字的验证码字符串
               """
        seeds = "1234567890"
        random_str = []
        for i in range(4):
            random_str.append(choice(seeds))

        return "".join(random_str)


        # figure = ''  # 定义空串)
        # chars = '1234567890'  # 定义随机可选的字符串
        # length = len(chars) - 1  #
        # random = Random()  # 调用Random方法 随机生成数字
        # # 根据生成的数字 到chars中去取对应的字符串，然后加在一起。
        # for i in range(randomlength):
        #     str += chars[random.randint(0, length)]
        # return figure